package com.woniu51.upload.service;

import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author 杨光
 * @date 2022年03月30日 16:24
 */
@Service
public class UploadService {


    public String upload(MultipartFile file){
        String fileName = System.currentTimeMillis()+"_"+file.getOriginalFilename();
        String url = null;
        try {
             url = OssManagerUtil.uploadImage(fileName, file.getSize(), file.getInputStream());
        } catch (IOException e) {
            e.printStackTrace();
            return "error";
        }
        return url;


    }
}
